package com.yy.pojo;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor//无参构造方法
@AllArgsConstructor//全参构造方法
@Data
public class Result<T> {

    private Integer code;
    private String message;
    private T data;
    //响应成功，返回data数据
    public static <E> Result<E> success(E data){
        return new Result(0,"操作成功", data);
    }
    //响应成功,没有返回数据
    public static Result success(){
        return new Result(0,"操作成功",null);
    }
    //响应失败,返回错误信息
    public static Result error(String message){
        return new Result(1,message,null);
    }
}
